package com.hz.zbl.controller;

import com.hz.zbl.model.dto.CourseStudentInfoDto;
import com.hz.zbl.model.dto.TeacherScheduleDTO;
import com.hz.zbl.model.entity.CourseEntity;
import com.hz.zbl.model.request.ApiResponse;
import com.hz.zbl.service.TeacherCourseService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/edu/teacher")
public class TeacherCourseController {

    @Resource
    TeacherCourseService teacherCourseService;

    @PostMapping("/check-score")
    public String checkScore(@RequestParam("user_score") int user_score,
                             @RequestParam("student_user_id") int student_user_id,
                             @RequestParam("course_code") String course_code){

        int result = teacherCourseService.checkScore(user_score,student_user_id,course_code);
        return result > 0 ? ApiResponse.ok(result) : ApiResponse.intError();
    }

    //教师课表
    @PostMapping("/schedule")
    public String teacherSchedule(@RequestParam("teacher_user_id") int teacher_user_id,
                                  @RequestParam(value = "course_year") Integer course_year,
                                  @RequestParam(value = "course_semester") Integer course_semester){

        List<TeacherScheduleDTO> res = teacherCourseService.teacherSchedule(teacher_user_id, course_year, course_semester);
        return res != null ? ApiResponse.ok(res) : ApiResponse.intError();
    }

    //教师所教课程学生信息列表
    @PostMapping("/schedule/student-info")
    public String teacherCourseStudentInfo(@RequestParam("teacher_user_id") int teacher_user_id,
                                           @RequestParam("course_code") String course_code){
        List<CourseStudentInfoDto> res = teacherCourseService.teacherCourseStudentInfo(teacher_user_id, course_code);
        return res != null ? ApiResponse.ok(res) : ApiResponse.intError();
    }




}
